package jmc.core.init.app.services;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.MalformedURLException;
import java.net.URL;
import java.sql.Timestamp;
import java.util.Properties;

import org.hibernate.SessionFactory;

public class ListenerSendTravelsWSService implements Runnable {

	public void run() {
		
		
		try {

			System.out.println("Inicio ListenerSendTravelService");
				
			Long periodo = 1500000l;
			
			while(true){					
				//String dominio = "localhost:8080";
				String dominio = "www.transfurlong.com.ar";
				String url = "http://" + dominio + "/" + "Trafico" + "/sendTravels.do?method=sendTravelsWS" ;
				openURL(url);
				Thread.sleep(periodo);
			}

		} catch (Exception e) {
			e.printStackTrace();
		}		
	}
	
	public void initListener(){
		Thread thread=new Thread(this);		 
		thread.start();	
	}
		
	private static void openURL(String url){
		URL method = null; 
		try {
			method = new URL(url);
		} catch (MalformedURLException e) {
			e.printStackTrace();
		}
		try {
			method.openStream();
		} catch (IOException e) {
			
			e.printStackTrace();
		}
	}

}
